<template>
  <div>
    <!-- <h2>我是Test组件{{ obj?.name }}</h2>
    父组件绑定的值---：{{ msg }} -->
    <!-- <HelloWorld @update:modelValue="eventToChild" :modelValue="msg"></HelloWorld> -->
    <!-- <HelloWorld v-model:msg="msg"></HelloWorld> -->
    Test组件{{msg}}
  </div>
</template>
<script lang="ts" setup>
  import {Ref, ref, inject} from 'vue'
  const msg = ref('测试全局组件')
  const obj: Ref<{name: string}> | undefined = inject('obj')
  // const p = () => new Promise((resolve) => {
  //   setTimeout(() => {
  //     resolve('123')
  //   }, 3000)
  // })
  // const a:any = await p()
  // msg.value = a
  console.log(obj?.value.name)
  // const eventToChild = (value: string) => {
  //   console.log(`我拿到子组件给我传的值了:${value}`)
  //   msg.value = value
  // }
</script>